package edu.sctu.nieyu.trainsystem;

import java.util.HashMap;

/**
 * Created by user01 on 2015/6/2.
 */
public class Card {

    private HashMap<String,Integer> map;

    public Card(){
        map =new TrainData().hashMapData();
    }
    public void getCard(String start,String end){

    }

    /**
     * 对乘客所乘地铁站数进行统计判断
     * @param start
     * @param end
     * @return
     */
    public int getCount(String start,String end){
        int count = 0;
        if (map.get(start)>map.get(end)){
            count = map.get(start)-map.get(end);
        }else {
            count = map.get(start)-map.get(end);
        }
        return count;
    }

    /**
     * 对乘客所乘站数对应的金额进行规定
     * @param start
     * @param end
     * @return
     */
    public int getPrice(String start,String end){
        int price = 2;
        if (getCount(start,end)<3){
            price = 2;
        }else if (getCount(start,end)>=3 && getCount(start,end)<6){
            price = 4;
        }else if (getCount(start,end)>=6 && getCount(start,end)<8){
            price = 5;
        }else if (getCount(start,end)>=8){
            price = 6;
        }
        return price;
    }

    /**
     * 余额不足时充值
     * @param price
     * @param passenger
     */
    public void setPrice(int price,Passenger passenger){
        passenger.setPrice(passenger.getPrice()+price);
    }

}
